package com.yfs.bus.builder;

import com.yfs.bus.entity.BasePrice;
import com.yfs.bus.entity.Bus;
import com.yfs.bus.entity.MaxBus;
import com.yfs.bus.entity.MiniBus;
import com.yfs.bus.exception.BussinessException;
import lombok.Data;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;

/**
 * @description: 出租车实例工厂
 * @param:
 * @return:
 * @author: xia
 * @time: 2022/4/13 11:45
 */
@Data
public class BusFactory {

    /**
     * @description: 获取出租车实例
     * @param: type，出租车类型，minKm。起步公里数，minPrice，起步价格，dayPriceMap，白天公里价格，nigthPriceMap，晚上公里价格
     * @return:
     * @author: xia
     * @time: 2022/4/13 14:19
     */
    public static Bus getInstance(Integer type,  LinkedList<BasePrice> dayPriceMap, LinkedList<BasePrice> nightPriceMap) {
        HashMap<Integer, LinkedList<BasePrice>> priceMap = new HashMap<>();
        priceMap.put(1, dayPriceMap);
        priceMap.put(2, nightPriceMap);
        if (type == 1) {
            return new MiniBus(priceMap);
        }
        if(type == 2){
            return new MaxBus(priceMap);
        }
        throw new BussinessException("没有找到对应类型的出租车");
    }

}
